package bishi.bilibili;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**
 * @Classname Main
 * @Description TODO
 * @Date 2021/9/13 20:16
 * @Created by ASUS
 */
public class Main {
    public static void main(String[] args) throws ParseException {
        Scanner scanner = new Scanner(System.in);
        String dateTime = scanner.nextLine();
        String[] ops = scanner.nextLine().split(" ");
        SimpleDateFormat sDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = sDF.parse(dateTime);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        for (String op : ops) {
            int a = Integer.parseInt(op.substring(0, op.length() - 1));
            switch (op.charAt(op.length() - 1)) {
                case 'W': {
                    calendar.add(Calendar.DAY_OF_YEAR, a * 7);
                    break;
                }
                case 'd': {
                    calendar.add(Calendar.DAY_OF_YEAR, a);
                    break;
                }
                case 'h': {
                    calendar.add(Calendar.HOUR, a);
                    break;
                }
                case 'm': {
                    calendar.add(Calendar.MINUTE, a);
                    break;
                }
                case 's': {
                    calendar.add(Calendar.SECOND, a);
                }
            }
        }
        Date startDate = calendar.getTime();
        String TIME = sDF.format(startDate);
        System.out.println(TIME);
    }
}
